<template>
  <div class="project">
    <div class="project-container">
      <div class="project-box">
        <div class="project-tit">
          <div class="tit-line">
            <span class="tit-line1"></span>
            <span class="tit-line2"></span>
          </div>
          <div class="solve-box">
            <div class="solve-tit">{{$t('contentDetails.AllTransportationSolutions')}}</div>
            <div class="solve-submit">
              <span>{{$t('contentDetails.AllTransportationDetails')}}</span>
            </div>
          </div>
          <div class="project-list">
            <el-row :gutter="20">
              <el-col :xs="24" :sm="24" :md="24" :lg="6" :xl="6" v-for="(item, index) in transportSolutions" :key="index" style="margin-bottom: 10px;">
                <div
                  class="item-box"
                  @mouseenter="hoverIndex = index"
                  @mouseleave="hoverIndex = -1"
                  @click="handleClick(item.id)"
                >
                  <div class="item-icon">
                    <img :src="baseUrl+item.iconUrl"/>
                  </div>
                  <div class="item-title">{{ item.title }}</div>
                  <div class="item-desc" :class="{ 'show-desc': hoverIndex === index }">
                    <div class="desc-content">
                      <h3>{{ item.title }}</h3>
                      <p>{{ item.description }}</p>
                    </div>
                  </div>
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script >
export default {
  props: {
    transportSolutions: {
      type: Array,
      default: () => []
    }
  },
  data(){
    return{
      hoverIndex: -1,
      routeMap:  ['/transport/rail', '/transport/sea','/transport/air', '/transport/road']

    }
  },
  computed: {
    baseUrl() {
      return process.env.VUE_APP_BASE_API
    }
  },
  methods: {
    handleClick(id) {
      const path = this.routeMap[id-1];
      if (path) {
        this.$router.push(path);
      } else {
        console.warn(`No route defined for title: ${title}`);
      }
    }
  }
}
</script>


<style scoped lang="scss">
/* 所有运输解决方案样式 */
.project, .network {
  background: url('~@/assets/asl_images/project_back.webp') no-repeat center center;
  background-size: contain;
}

.network {
  background: url('~@/assets/asl_images/project_back.webp') no-repeat top center;
  padding-top: 20px;
}

.project-container {
  max-width: 1200px;
  margin: 80px auto 20px;
  padding: 0 20px;
}

.project-tit {
  text-align: left;
  margin-bottom: 50px;
}

.tit-line {
  display: flex;
  justify-content: left;
  margin-bottom: 20px;
}

.tit-line1, .tit-line2 {
  height: 8px;
  background: #fe3231;
  border-radius: 10px;
}

.tit-line1 {
  width: 60px;
}

.tit-line2 {
  width: 10px;
  margin-left: 10px;
}

.solve-tit {
  font-size: 30px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
  text-align: left;
}

.solve-submit {
  font-size: 16px;
  color: #666;
  line-height: 1.6;
}

.solve-submit span {
  display: block;
  margin-bottom: 5px;
}

.project-list {
  margin-top: 50px;
}

.item-box {
  position: relative;
  height: 430px;
  background-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  overflow: hidden;
  text-align: center;
  cursor: pointer;

  .item-title {
    transition: all 0.4s ease; // 增加过渡动画
  }

  // 悬停状态
  &:hover {
    .item-title {
      opacity: 0;
      transform: translateY(20px); // 向下移动隐藏
    }

    .item-desc {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

.item-icon {
  width: 100%;
  height: 100%;
}

.item-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: all 0.3s ease;
}

.item-title {
  font-size: 18px;
  padding: 15px 0;
  color: #333;
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
}

.item-desc {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
  padding: 15px;
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: left;
}

.item-desc.show-desc {
  opacity: 1;
  transform: translateY(0);
}

.desc-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;
}

.desc-content h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

.desc-content p {
  font-size: 14px;
  line-height: 1.8;
  color: #333;
}

/* 媒体查询：为小屏幕设备添加移动端样式 */
@media (max-width: 768px) {
  .project-container {
    max-width: 100%;
    margin: 40px 0 20px;
    padding: 0 15px;
  }

  .project-tit {
    margin-bottom: 30px;
  }

  .solve-tit {
    font-size: 24px;
    margin-bottom: 10px;
  }

  .solve-submit {
    font-size: 14px;
  }

  .project-list {
    margin-top: 30px;
  }



  .item-box {
    height: 300px;
    min-height: 250px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }

  .item-title {
    font-size: 16px;
    padding: 10px 0;
  }

  .item-desc {
    padding: 10px;
  }

  .desc-content h3 {
    font-size: 16px;
    margin-bottom: 15px;
  }

  .desc-content p {
    font-size: 12px;
    line-height: 1.6;
  }
}

/* 媒体查询：为更小屏幕设备进一步优化样式 */
@media (max-width: 480px) {
  .project-container {
    margin: 30px 0 15px;
  }

  .solve-tit {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .solve-submit {
    font-size: 12px;
  }

  .solve-submit span {
    margin-bottom: 3px;
  }

  .project-list {
    margin-top: 20px;
  }


  .item-box {
    height: 250px;
    min-height: 200px;
  }

  .item-title {
    font-size: 14px;
    padding: 8px 0;
  }

  .desc-content h3 {
    font-size: 14px;
    margin-bottom: 10px;
  }

  .desc-content p {
    font-size: 10px;
    line-height: 1.4;
  }
}
</style>
